﻿package com.mui.controls
{
    import com.gengine.debug.*;
    import com.gengine.global.*;
    import com.mui.manager.*;
    import com.mui.utils.*;
    import flash.events.*;
    import flash.text.*;

    public class GTextFiled extends TextField implements IToolTipItem, IFrUI, IData
    {
        private var _isDisposed:Boolean;
        private var _toolTipData:Object;
        private var _reactionTime:int = 500;
        private var _Data:Object;

        public function GTextFiled()
        {
            this.addEventListener(Event.ADDED_TO_STAGE, this.judgeToolTip);
            this.addEventListener(Event.REMOVED_FROM_STAGE, this.judgeToolTip);
            this.addEventListener(TextEvent.LINK, this.onTextLink);
            return;
        }// end function

        public function get toolTipData()
        {
            return this._toolTipData;
        }// end function

        public function set toolTipData(param1) : void
        {
            this._toolTipData = param1;
            this.judgeToolTip();
            return;
        }// end function

        public function get reactionTime() : int
        {
            return this._reactionTime;
        }// end function

        public function set reactionTime(param1:int) : void
        {
            this._reactionTime = param1;
            return;
        }// end function

        protected function judgeToolTip(event:Event = null) : void
        {
            if (event && event.type == Event.ADDED_TO_STAGE && this.toolTipData || !event && this.toolTipData && Global.stage.contains(this))
            {
                ToolTipsManager.register(this);
            }
            else
            {
                ToolTipsManager.unregister(this);
            }
            return;
        }// end function

        protected function onTextLink(event:TextEvent) : void
        {
            return;
        }// end function

        override public function set htmlText(param1:String) : void
        {
            var _loc_2:String = null;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            if (param1 == null)
            {
                param1 = "";
            }
            super.htmlText = param1;
            if (Global.isDebugModle)
            {
                _loc_2 = param1;
                _loc_3 = _loc_2.indexOf("<u><a");
                while (_loc_3 >= 0)
                {
                    
                    _loc_2 = _loc_2.substr(_loc_3 + 5);
                    _loc_4 = _loc_2.indexOf("</a></u>");
                    if (_loc_4 < 0)
                    {
                        Log.error("找到不规范文本，text=" + param1);
                        if (Global.isDebugModle)
                        {
                            Alert.show("找到不规范文本，text=" + param1);
                        }
                    }
                    _loc_3 = _loc_2.indexOf("<u><a");
                }
                _loc_2 = param1;
                _loc_3 = _loc_2.indexOf("<font");
                while (_loc_3 >= 0)
                {
                    
                    _loc_2 = _loc_2.substr(_loc_3 + 5);
                    _loc_4 = _loc_2.indexOf("</font>");
                    if (_loc_4 < 0)
                    {
                        param1 = param1.replace("<font", "");
                        Log.error("找到不规范文本，text=" + param1);
                        if (Global.isDebugModle)
                        {
                            Alert.show("找到不规范文本，text=" + param1);
                        }
                    }
                    _loc_3 = _loc_2.indexOf("<font");
                }
            }
            return;
        }// end function

        public function configEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
        {
            ObjEventListerTool.addObjEvent(this, param1, param2, param3);
            addEventListener(param1, param2, param3, param4, param5);
            return;
        }// end function

        public function set isDisposed(param1:Boolean) : void
        {
            this._isDisposed = param1;
            return;
        }// end function

        override public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
        {
            ObjEventListerTool.removeObjEvent(this, param1, param2, param3);
            super.removeEventListener(param1, param2, param3);
            return;
        }// end function

        public function dispose(param1:Boolean = true) : void
        {
            if (this._isDisposed && param1)
            {
                if (Global.isDebugModle)
                {
                    Alert.show("存在组件二次释放" + this.toString());
                }
                return;
            }
            this.text = "";
            embedFonts = false;
            width = 100;
            height = 20;
            ObjEventListerTool.delObjEvent(this);
            var _loc_2:* = this.defaultTextFormat;
            _loc_2.align = TextFormatAlign.LEFT;
            _loc_2.bold = false;
            _loc_2.underline = false;
            _loc_2.size = 12;
            _loc_2.letterSpacing = 0;
            _loc_2.underline = false;
            _loc_2.italic = false;
            _loc_2.indent = 0;
            _loc_2.leading = 0;
            this.defaultTextFormat = _loc_2;
            this.autoSize = TextFieldAutoSize.NONE;
            this.mouseEnabled = true;
            this.multiline = false;
            this.wordWrap = false;
            this.border = false;
            if (this.parent)
            {
                this.parent.removeChild(this);
            }
            if (param1)
            {
                UICompomentPool.disposeUICompoment(this);
            }
            this._reactionTime = 500;
            return;
        }// end function

        public function get Data()
        {
            return this._Data;
        }// end function

        public function set Data(param1) : void
        {
            this._Data = param1;
            return;
        }// end function

        override public function set text(param1:String) : void
        {
            if (param1 == null)
            {
                param1 = "";
            }
            super.text = param1;
            return;
        }// end function

    }
}
